package com.example.compose

import androidx.compose.runtime.toMutableStateList
import androidx.lifecycle.ViewModel

class WellnessViewModel : ViewModel() {

    private val _tasks = getWellnessTasks().toMutableStateList()
    val task: List<WellnessTask>
        get() = _tasks

    fun remove(task: WellnessTask) {
        _tasks.remove(task)
    }

    fun changeTaskChecked(item: WellnessTask, checked: Boolean) = _tasks.find {
        it.id == item.id
    }?.let { task -> task.checked = true }

}

private fun getWellnessTasks() = List(30) { i -> WellnessTask(id = i, label = "Task # $i") }